package queue;

import java.util.Random;

/**
 * @author lynn
 * @date 18-12-14 上午10:50
 */
public class TestMain {

    private static final int opTimes = 100000;

    private static double testQueue(Queue queue, int times) {

        long start = System.nanoTime();

        Random random = new Random();

        for (int i = 0; i < times; i++) {
            queue.enqueue(random.nextInt(Integer.MAX_VALUE));
        }

        for (int i = 0; i < times; i++) {
            queue.dequeue();
        }

        long end = System.nanoTime();

        return (end - start) / 1000000000.0;

    }


    public static void main(String[] args) {

        ArrayQueue<Integer> arrayQueue = new ArrayQueue<>();
        System.out.println( "array queue " + testQueue(arrayQueue, opTimes));

        LoopQueue<Integer> loopQueue = new LoopQueue<>();
        System.out.println("loop queue " + testQueue(loopQueue,opTimes));


    }


}
